import { ApiProperty } from '@nestjs/swagger';
import { IsOptional, IsString } from 'class-validator';
import { Transform } from 'class-transformer';

export class AutoLoginDto {
  @ApiProperty({
    description: '登录类型 oa|simple|other',
    default: 'oa',
  })
  @IsString()
  @IsOptional()
  @Transform(({ value }) => {
    if (value === undefined) {
      return 'oa';
    } else {
      return value;
    }
  })
  type: string;
  @ApiProperty({
    description: '认证密钥, simple模式为 username_md5(password)',
    default: null,
  })
  @IsString()
  ticket: string;
}
